package physical.equation.math;

public class MatrixTool
{
	//calc inverse matrix for 2-dimensional cases
	public static double[][] inverse(double[][] matrix)
	{
		double[][] ans = new double[2][2];
		
		double det = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
		ans[0][0] = +matrix[1][1] / det;
		ans[0][1] = -matrix[1][0] / det;
		ans[1][0] = -matrix[0][1] / det;
		ans[1][1] = +matrix[0][0] / det;
		
		return ans;
	}
}